import { Entity, PrimaryGeneratedColumn, Column, DeleteDateColumn, Index, OneToOne, UpdateDateColumn, CreateDateColumn} from "typeorm";
import { Book } from "src/modules/books/entities/book.entity";
@Index(['category_name'],{ unique: true })
@Entity('category_tb')
export class Category {
    @PrimaryGeneratedColumn({ comment: '分类id'})
    id: number;
    @Column({ name: 'category_name', default: null, comment:'分类名称' })
    category_name:string;
    @CreateDateColumn({ name: 'create_time', comment:'创建时间' })
    create_time:Date;
    @UpdateDateColumn({ name: 'update_time',  comment:'更新时间' })
    update_time:Date;
    @DeleteDateColumn({ select: false, name: 'delete_time', comment:'删除时间' })
    delete_time:Date;
    @OneToOne(()=> Book, (book) => book.category_id)
    book:Book;
}
